package com.vagavaga.bizworld.jpatx;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import javax.persistence.EntityTransaction;

abstract class EntityTransactionInterceptor implements InvocationHandler {
    protected static final Method BEGIN;
    protected static final Method COMMIT;
    protected static final Method GET_ROLLBACK_ONLY;
    protected static final Method IS_ACTIVE;
    protected static final Method ROLLBACK;
    protected static final Method SET_ROLLBACK_ONLY;

    static {
        try {
            BEGIN = EntityTransaction.class.getMethod("begin", (Class<?>[]) null); //$NON-NLS-1$
            COMMIT = EntityTransaction.class.getMethod("commit", (Class<?>[]) null); //$NON-NLS-1$
            GET_ROLLBACK_ONLY = EntityTransaction.class.getMethod("getRollbackOnly", (Class<?>[]) null); //$NON-NLS-1$
            IS_ACTIVE = EntityTransaction.class.getMethod("isActive", (Class<?>[]) null); //$NON-NLS-1$
            ROLLBACK = EntityTransaction.class.getMethod("rollback", (Class<?>[]) null); //$NON-NLS-1$
            SET_ROLLBACK_ONLY = EntityTransaction.class.getMethod("setRollbackOnly", (Class<?>[]) null); //$NON-NLS-1$
        } catch (Exception e) {
            throw new ExceptionInInitializerError("Unable to initialize");
        }
    }
}
